var RunLayer = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callKill = cc.callFunc(function(p){
			var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
				p.removeFromParent(true);	
			}, this));
			p.runAction(seq);
		}, this); 
		
		this.callNext.retain();
		this.callKill.retain();
		//时钟
		this.clock = new Clock(this);
//		// 物品库
		this.lib = new Lib(this);
		//蓄电池
		this.loadBattery();
		//实验烧瓶
		this.flask = new Flask(this);
		//电流表
		this.ammeter = new Ammeter(this);
		//滑动变阻器
		this.rhostat = new Rhostat(this);
		//开关
		this.switchcraft = new Switchcraft(this);
		//导线
		this.guideline = new GuideLine(this);
	},
	loadBattery:function(pos){
		var battery = new Button(this, 10, TAG_BATTERY, "#battery.png", this.callback);
		battery.setPosition(cc.p(250,250));
	},
	loadInLib:function(obj, pos, tarPos,next,delay){
		obj.setPosition(pos);
		if(next == null){
			next = true;
		}
		if(delay == null){
			delay = 1;
		}		
		var ber = $.bezier(pos, tarPos, delay);
		if(next){
			var seq = cc.sequence(ber, this.callNext);
		}else{
			var seq = cc.sequence(ber);
		}	
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	},
	
	callback:function (p){
		var func = cc.callFunc(this.actionDone, this);
		var action=gg.flow.flow.action;
		switch(p.getTag()){
		   case TAG_NAOH_LID:
				break;
		}
	},
	actionDone:function(p){
		var func = cc.callFunc(this.actionDone, this);
		switch(p.getTag()){
			case TAG_PAPER:
				
				break;
			case TAG_SPOON:
				
				break;
		}
	},
	flowNext:function(){
		gg.flow.next();
	},
	onExit:function(){
		this._super();
		this.callNext.release();
		this.callKill.release();
	}
});